package com.cencat.merchant.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 派单统计VO
 * 
 * @author cencat
 * @since 2024
 */
@Data
@Schema(description = "派单统计信息")
public class DispatchStatisticsVO {
    
    @Schema(description = "总派单数")
    private Long totalDispatchCount;
    
    @Schema(description = "成功派单数")
    private Long successDispatchCount;
    
    @Schema(description = "失败派单数")
    private Long failedDispatchCount;
    
    @Schema(description = "派单成功率")
    private BigDecimal successRate;
    
    @Schema(description = "平均响应时间（秒）")
    private BigDecimal avgResponseTime;
    
    @Schema(description = "平均匹配度")
    private BigDecimal avgMatchScore;
    
    @Schema(description = "平均距离（公里）")
    private BigDecimal avgDistance;
    
    @Schema(description = "各派单类型统计")
    private Map<String, Long> dispatchTypeStats;
    
    @Schema(description = "各状态统计")
    private Map<String, Long> statusStats;
    
    @Schema(description = "每日派单趋势")
    private List<DailyDispatchTrend> dailyTrends;
    
    @Schema(description = "司机派单排行")
    private List<DriverDispatchRank> driverRanks;
    
    @Schema(description = "商家派单排行")
    private List<MerchantDispatchRank> merchantRanks;
    
    /**
     * 每日派单趋势
     */
    @Data
    @Schema(description = "每日派单趋势")
    public static class DailyDispatchTrend {
        
        @Schema(description = "日期")
        private String date;
        
        @Schema(description = "派单数量")
        private Long count;
        
        @Schema(description = "成功数量")
        private Long successCount;
        
        @Schema(description = "成功率")
        private BigDecimal successRate;
    }
    
    /**
     * 司机派单排行
     */
    @Data
    @Schema(description = "司机派单排行")
    public static class DriverDispatchRank {
        
        @Schema(description = "司机ID")
        private Long driverId;
        
        @Schema(description = "司机姓名")
        private String driverName;
        
        @Schema(description = "派单数量")
        private Long dispatchCount;
        
        @Schema(description = "成功数量")
        private Long successCount;
        
        @Schema(description = "成功率")
        private BigDecimal successRate;
        
        @Schema(description = "平均评分")
        private BigDecimal avgRating;
    }
    
    /**
     * 商家派单排行
     */
    @Data
    @Schema(description = "商家派单排行")
    public static class MerchantDispatchRank {
        
        @Schema(description = "商家ID")
        private Long merchantId;
        
        @Schema(description = "商家名称")
        private String merchantName;
        
        @Schema(description = "派单数量")
        private Long dispatchCount;
        
        @Schema(description = "成功数量")
        private Long successCount;
        
        @Schema(description = "成功率")
        private BigDecimal successRate;
        
        @Schema(description = "平均响应时间")
        private BigDecimal avgResponseTime;
    }
}